package com.ziyun.erp.web.modules.capital.controller;

import java.util.Arrays;
import java.util.Map;

import com.baomidou.mybatisplus.plugins.Page;
import com.ziyun.erp.modules.message.entity.MessageEntity;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ziyun.erp.modules.capital.entity.RemittanceMerchantsEntity;
import com.ziyun.erp.modules.capital.service.RemittanceMerchantsService;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.common.validator.ValidatorUtils;

/**
 * 供应商打款信息表
 *
 * @author zh
 * @email 296588519@qq.com
 * @date 2018-08-06 15:38:25
 */
@RestController
@RequestMapping("capital/remittancemerchants")
public class RemittanceMerchantsController {
	@Autowired
	private RemittanceMerchantsService remittanceMerchantsService;

	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("capital:remittancemerchants:list")
	public R list(@RequestBody QueryPage<RemittanceMerchantsEntity> query ) {
		remittanceMerchantsService.queryPage(query.getPage(),query.getParams());
		return R.ok().put("page", query.getPage());
	}

	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("capital:remittancemerchants:info")
	public R info(@PathVariable("id") Integer id) {
		RemittanceMerchantsEntity remittanceMerchants = remittanceMerchantsService.selectById(id);

		return R.ok().put("remittanceMerchants", remittanceMerchants);
	}

	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("capital:remittancemerchants:save")
	public R save(@RequestBody RemittanceMerchantsEntity remittanceMerchants) {
		remittanceMerchantsService.insert(remittanceMerchants);

		return R.ok();
	}

	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("capital:remittancemerchants:update")
	public R update(@RequestBody RemittanceMerchantsEntity remittanceMerchants) {
		ValidatorUtils.validateEntity(remittanceMerchants);
		remittanceMerchantsService.updateAllColumnById(remittanceMerchants);// 全部更新

		return R.ok();
	}

	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("capital:remittancemerchants:delete")
	public R delete(@RequestBody Integer[] ids) {
		remittanceMerchantsService.deleteBatchIds(Arrays.asList(ids));

		return R.ok();
	}

}
